home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gekikoh Dennoh Club 1
/
Gekikoh Dennoh Club Vol. 1 (Japan).7z
/
Gekikoh Dennoh Club Vol. 1 (Japan) (Track 1).bin
/
kowin
/
archive
/
net
/
chatwins.lzh
/
chatwin.c
next >
Wrap
C/C++ Source or Header
|
1994-10-14
|
5KB
|
232 lines
/* Copyright 1993 H.Ogasawara (COR.) */
#include <corlib.h>
#define MAXCHAR 160
#define FONT 12
#define Ctrl(a) ((a)&0x1f)
short font= FONT,
fontx= FONT/2,
attr= 9,
crmode= 1;
int usercode= UserPaste;
short maxchar= MAXCHAR;
int WindowHeapSize= 1024*8;
char progname[30],
header[30];
static char *username[]= {
"UserPaste", "UserString", "UserStrings", "UserSheet" };
send_k20string( msg, cr )
char *msg;
{
EventInfo info;
if( cr )
strcat( msg, "\r\0Copyright 1993-94 H.Ogasawara (COR.)" );
info.option= EventUser;
info.ComData= usercode;
info.ComBuffer= msg;
PidSendEvent( progname, &info, TRUE );
}
pos_set( wp, input )
WindowID wp;
InputClass *input;
{
int x, y, h;
int cur= InputGetCursor(input)*fontx;
WindowGetHome( wp, &x, &y );
WindowGetViewSize( wp, &h, &y );
if( cur >= x+h-font ){
WindowScroll( wp, cur-x-h+12+8*fontx, 0 );
return TRUE;
}else if( cur < x ){
WindowScroll( wp, cur-x-8*fontx, 0 );
return TRUE;
}
return FALSE;
}
init_input( wp, ibuf, input )
WindowID wp;
char *ibuf;
InputClass *input;
{
strcpy( ibuf, header );
InputSet( input, 0, 0, ibuf, maxchar, attr, font );
golast_input( wp, ibuf, input );
}
golast_input( wp, ibuf, input )
WindowID wp;
char *ibuf;
InputClass *input;
{
InputSetCursor( input, strlen( ibuf ) );
if( !pos_set( wp, input ) )
input_redraw( wp, input );
}
input_redraw( wp, input )
WindowID wp;
InputClass *input;
{
DrawBuf dbuf[20];
DrawSetClear( dbuf, attr&AttrReverse?attr&3:0 );
WindowDraw( wp, dbuf, 1+InputSetDraw( dbuf+1, input ) );
}
Exec( wp, info )
WindowID wp;
EventInfo *info;
{
DrawBuf dbuf[20];
static InputClass input;
static char ibuf[MAXCHAR+4];
static short histflag= FALSE;
int i;
switch( info->option ){
case EventOpen:
init_input( wp, ibuf, &input );
return FALSE;
case EventRedraw:
input_redraw( wp, &input );
return TRUE;
case EventMouseSwitch:
if( info->LeftON ){
SendData( WindowGetParent(wp), info, UserString, ibuf );
return TRUE;
}
break;
case EventMouseEnter:
case EventMouseOut:
WindowDraw( wp, dbuf, InputSetCursorVisible( dbuf, &input,
info->option == EventMouseEnter ) );
return TRUE;
case EventKey:
i= 0;
switch( info->KeyCode ){
case Ctrl('e'):
if( InputGetMode() )
goto Nfunc;
goto up_history;
case Ctrl('p'):
if( !InputGetMode() )
goto Nfunc;
case FuncKeyRollDown:
case Ctrl('w'):
up_history:
i= 1;
case FuncKeyRollUp:
case Ctrl('x'):
case Ctrl('n'):
getnexthist( ibuf, histflag, i );
golast_input( wp, ibuf, &input );
histflag= TRUE;
return TRUE;
case '\r':
i= crmode;
case '\n': {
int x, y;
histflag= FALSE;
addhist( ibuf );
send_k20string( ibuf, i );
init_input( wp, ibuf, &input );
WindowGetHome( wp, &x, &y );
if( x )
WindowScroll( wp, -maxchar*fontx+100, 0 );
}
return TRUE;
default:
if( info->KeyCode >= FuncKey+1 &&
info->KeyCode <= FuncKey+20 ){
keyinput( wp, info->KeyCode-FuncKey-1 );
return TRUE;
}
histflag= FALSE;
case Ctrl('a'):
case Ctrl('q'):
Nfunc:
WindowDraw( wp, dbuf,
InputKey( dbuf, &input, info->KeyCode,
info->ShiftStat ) );
pos_set( wp, &input );
}
return TRUE;
}
return FALSE;
}
WindowMain( argc, argv )
char **argv;
{
int i;
char *title= "ChatWin v1.21";
strcpy( progname, "k20.win" );
*header= '\0';
for( i= 0 ; i< argc ; i++ ){
if( *(argv[i]) == '-' ){
switch( argv[i][1] ){
case 't':
title= argv[i]+2;
break;
case 'c':
crmode= 0;
break;
case 'a':
attr= atoi2( argv[i]+2 );
break;
case 'm':
strcpy( header, argv[i]+2 );
break;
case 'p':
strcpy( progname, argv[i]+2 );
break;
case 'r':
if( !read_fncfile( argv[i]+2 ) ){
ConsoleOpen();
ConsolePrint( "chatwin:ファンクションキーファイルが読めません\r\n" );
}
break;
case 'f':
fontx= (font= atoi2(argv[i]+2))/2;
if( fontx == 5 )
maxchar= MAXCHAR;
else if( fontx == 12 )
maxchar= 82;
else if( fontx == 8 )
maxchar= 120;
else
maxchar= MAXCHAR,
fontx= (font= FONT)/2;
break;
case 'u':
{
int j;
char *p= argv[i]+2;
for( j= 0 ; j< 4 ; j++ ){
if( !strcmp(p,username[j]) ){
usercode= j;
break;
}
}
if( j == 4 ){
if( *p >= '0' && *p <= '9' )
usercode= atoi2(p);
else for( usercode= 0 ; *p ;
usercode<<=8,
usercode+= *p++ );
}
}
break;
}
}
}
MgWindowScrollOpenArgs( 100, 100, 80*6+14, 14+font, title,
argc, argv, maxchar*fontx, font, Icon|Zoom, Exec );
}